import { createRouter, createWebHistory } from 'vue-router'
import Login from '@/views/Login.vue'
import Register from '@/views/Register.vue'
import NotFound from '@/views/NotFound.vue'

const routes = [
  {
    path: '/',
    redirect: '/login'
  },
  {
    path: '/login',
    name: 'Login',
    component: Login
  },
  {
    path: '/admin',
    name: 'Admin',
    component: () => import('@/views/admin/index.vue'),
    children: [
      {
        path: 'users',
        name: 'UserManagement',
        component: () => import('@/views/admin/UserManagement.vue')
      },
      {
        path: 'departments',
        name: 'DepartmentManagement',
        component: () => import('@/views/admin/DepartmentManagement.vue')
      },
      {
        path: 'roles',
        name: 'RoleManagement',
        component: () => import('@/views/admin/RoleManagement.vue')
      }
    ]
  },
  {
    path: '/scheduler',
    name: 'Scheduler',
    component: () => import('@/views/scheduler/index.vue'),
    children: [
      {
        path: 'schedules',
        name: 'ScheduleManagement',
        component: () => import('@/views/scheduler/ScheduleManagement.vue')
      },
      {
        path: 'holidays',
        name: 'HolidayManagement',
        component: () => import('@/views/scheduler/HolidayManagement.vue')
      }
    ]
  },
  {
    path: '/medical',
    name: 'Medical',
    component: () => import('@/views/medical/index.vue'),
    children: [
      {
        path: 'shiftchanges',
        name: 'ShiftChangeManagement',
        component: () => import('@/views/medical/ShiftChangeManagement.vue')
      },
      {
        path: 'leaveapplications',
        name: 'LeaveApplicationManagement',
        component: () => import('@/views/medical/LeaveApplicationManagement.vue')
      },
      {
        path: 'messages',
        name: 'MessageManagement',
        component: () => import('@/views/medical/MessageManagement.vue')
      }
    ]
  },
  {
    path: '/register',
    name: 'Register',
    component: Register
  },
  {
    path: '/404',
    name: 'NotFound', 
    component: NotFound
  },
  {
    path: '/:pathMatch(.*)*',
    name: 'NotFound', 
    component: NotFound
  }
]

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes
})

export default router